#ifndef _CONFIG__H_
#define _CONFIG__H_

#include "params/dtype.h"

/*------------------------*/
#define RELU(A) ((A) > 0 ? (A) : 0)
#define MAX(A, B) ((A) > (B) ? (A) : (B))
/*------------------------*/


#define C1_IN_CH        1
#define C1_OUT_CH       6
#define C1_KER_SIZE     5
#define C1_IN_SIZE      32
#define C1_OUT_SIZE     28

#define C2_IN_CH        6
#define C2_OUT_CH       16
#define C2_KER_SIZE     5
#define C2_IN_SIZE      14
#define C2_OUT_SIZE     10

#define FC1_IN_SIZE     400
#define FC1_OUT_SIZE    120

#define FC2_IN_SIZE     120
#define FC2_OUT_SIZE    84

#define FC3_IN_SIZE     84
#define FC3_OUT_SIZE    10

/***************************/
void lenet_c1_int8(
    INT8 din[C1_IN_CH][C1_IN_SIZE][C1_IN_SIZE],
    INT8 ker[C1_OUT_CH][C1_IN_CH][C1_KER_SIZE][C1_KER_SIZE],
    INT32 dout[C1_OUT_CH][C1_OUT_SIZE][C1_OUT_SIZE]);

void lenet_c1_bias_relu(
    INT32 din[C1_OUT_CH][C1_OUT_SIZE][C1_OUT_SIZE],
    dtype bias[C1_OUT_CH],
    dtype scale,
    dtype dout[C1_OUT_CH][C1_OUT_SIZE][C1_OUT_SIZE]);

void lenet_mp1(
    dtype din[C1_OUT_CH][C1_OUT_SIZE][C1_OUT_SIZE],
    dtype dout[C1_OUT_CH][C1_OUT_SIZE/2][C1_OUT_SIZE/2]);

void lenet_mp2(
    dtype din[C2_OUT_CH][C2_OUT_SIZE][C2_OUT_SIZE],
    dtype dout[C2_OUT_CH][C2_OUT_SIZE/2][C2_OUT_SIZE/2]);

void lenet_c2_int8(
    INT8 din[C2_IN_CH][C2_IN_SIZE][C2_IN_SIZE],
    INT8 ker[C2_OUT_CH][C2_IN_CH][C2_KER_SIZE][C2_KER_SIZE],
    INT32 dout[C2_OUT_CH][C2_OUT_SIZE][C2_OUT_SIZE]);

void lenet_c2_bias_relu(
    INT32 din[C2_OUT_CH][C2_OUT_SIZE][C2_OUT_SIZE],
    dtype bias[C2_OUT_CH],
    dtype scale,
    dtype dout[C2_OUT_CH][C2_OUT_SIZE][C2_OUT_SIZE]);

void lenet_fc1(
    dtype d_in[FC1_IN_SIZE],
    dtype d_out[FC1_OUT_SIZE],
    dtype weights[FC1_OUT_SIZE][FC1_IN_SIZE],
    dtype bias[FC1_OUT_SIZE]);

void lenet_fc2(
    dtype d_in[FC2_IN_SIZE],
    dtype d_out[FC2_OUT_SIZE],
    dtype weights[FC2_OUT_SIZE][FC2_IN_SIZE],
    dtype bias[FC2_OUT_SIZE]);

void lenet_fc3(
    dtype d_in[FC3_IN_SIZE],
    dtype d_out[FC3_OUT_SIZE],
    dtype weights[FC3_OUT_SIZE][FC3_IN_SIZE],
    dtype bias[FC3_OUT_SIZE]);

#endif
